package main

import (
	"./appearance"
	"fmt"
	"pkg.deepin.io/lib/dbus"
)

func testList() {
	m := appearance.NewManager()
	list, err := m.List(appearance.TypeDTheme)
	fmt.Println("DTheme:", list, err)
	list, err = m.List(appearance.TypeGtkTheme)
	fmt.Println("GtkTheme:", list, err)
	list, err = m.List(appearance.TypeIconTheme)
	fmt.Println("IconTheme:", list, err)
	list, err = m.List(appearance.TypeCursorTheme)
	fmt.Println("CursorTheme:", list, err)
	list, err = m.List(appearance.TypeBackground)
	fmt.Println("Background:", list, err)
	list, err = m.List(appearance.TypeStandardFont)
	fmt.Println("Standard:", list, err)
	list, err = m.List(appearance.TypeMonospaceFont)
	fmt.Println("Monospace:", list, err)
}

func testShow() {
	m := appearance.NewManager()
	text, err := m.Show(appearance.TypeDTheme, "Deepin")
	fmt.Println("DTheme Deepin:", text, err)

	text, err = m.Show(appearance.TypeGtkTheme, "Deepin")
	fmt.Println("Gtk Deepin:", text, err)

	text, err = m.Show(appearance.TypeGtkTheme, "Zukitwo")
	fmt.Println("Gtk Zukitwo:", text, err)

	text, err = m.Show(appearance.TypeIconTheme, "Deepin")
	fmt.Println("Icon Deepin:", text, err)

	text, err = m.Show(appearance.TypeCursorTheme, "Deepin-Cursor")
	fmt.Println("Cursor Deepin:", text, err)

	text, err = m.Show(appearance.TypeBackground, "file:///usr/share/backgrounds/desktop.jpg")
	fmt.Println("Background default:", text, err)

	text, err = m.Show(appearance.TypeStandardFont, "Source Han Sans SC")
	fmt.Println("Standard:", text, err)

	text, err = m.Show(appearance.TypeMonospaceFont, "Source Code Pro")
	fmt.Println("Monospace:", text, err)
}

func main() {
	m := appearance.NewManager()

	err := dbus.InstallOnSession(m)
	if err != nil {
		fmt.Println("Install dbus failed:", err)
		return
	}
	dbus.DealWithUnhandledMessage()

	err = dbus.Wait()
	if err != nil {
		fmt.Println("Losing dbus:", err)
	}
}
